package middleware

import (
	"Software/global"
	"github.com/gin-gonic/gin"
)

func AccessLog() gin.HandlerFunc {
	return func(c *gin.Context) {
		clientIp := c.ClientIP()
		reqMethod := c.Request.Method
		reqURI := c.Request.RequestURI
		statusCode := c.Writer.Status()

		global.Logger.Infof("| %s | %s | %s | %d ",
			clientIp,
			reqMethod,
			reqURI,
			statusCode,
		)
	}
}
